﻿// Copyright (c) Sustainsys AB. All rights reserved.
// Licensed under the MIT license. See LICENSE in the project root for license information.

using Sustainsys.Saml2.Saml;
using Sustainsys.Saml2.Xml;

namespace Sustainsys.Saml2.Serialization;
public partial class SamlXmlReader
{
    /// <summary>
    /// Read a NameId
    /// </summary>
    /// <param name="source">Xml Traverser to read from</param>
    /// <returns>NameId</returns>
    protected virtual NameId ReadNameId(XmlTraverser source)
    {
        var result = Create<NameId>();

        // Read the text value of the NameID element and the Format attribute
        result.Value = source.GetTextContents();
        result.Format = source.GetAbsoluteUriAttribute("Format");

        return result;
    }
}